<template>
  <div style="display: flex;line-height: 60px">
  <div>
    <i :class="icon" style="font-size: 20px;" @click="doCollapse"></i>
  </div>
    <div style="flex:1;text-align:center;font-size: 30px">
      <span>体育赛事足球世界杯管理系统</span>
    </div>
    <el-dropdown>
      <span>{{user.account}}</span><i class="el-icon-s-custom" style="margin-right: 10px"></i>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item @click.native="toUser">个人中心</el-dropdown-item>
      <el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>

  </div>

</template>

<script>
export default {
  name: " Header",
  data(){
    return{
      user:JSON.parse(sessionStorage.getItem('CurUser'))
    }
  },
  props:{//接收
    icon:String
  },
  methods:{
    toUser(){
      console.log("to_user")
      this.$router.push("/Home")
    },
    logout(){
      console.log("log_out")
      this.$confirm("您确定要退出登录吗？","提示",{
        confirmButtonText:"确定",
        type:"warning",
        center:true
      }).then(()=>{
        this.$message({
          type:"success",
          message:"退出登录成功"
        })
        this.$router.push("/")
        sessionStorage.clear()
      }).catch(()=>{
        this.$message({
          type:"info",
          message:"已取消退出登录"
        })
      })

    },
    doCollapse(){
      this.$emit("doCollapse")//传递给父组件
    }
  },
  created() {
    this.$router.push("/Home")
  }
}
</script>

<style scoped>

</style>